<%@ page language="java" contentType="text/html; charset=utf-8"
         pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<html>
<head>
    <title>医生查询列表页面</title>
    <link href="<%=basePath%>css/style.css" rel="stylesheet" type="text/css" />
    <link href="<%=basePath%>css/select.css" rel="stylesheet" type="text/css" />
    <link href="<%=basePath%>css/bootstrap.min.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="<%=basePath%>js/jquery.min.js"></script>
    <script type="text/javascript" src="<%=basePath%>js/select-ui.min.js"></script>
    <script type="text/javascript">
        function doctchangeStatus(docid,status){
            if(status=='1'){
                if (confirm("您确定要禁用该用户吗?")){
                    document.form1.action="<%=basePath%>doctchangeStatus?docid="+docid+"&sts=0";
                    document.form1.submit();
                }
            }else{
                if (confirm("您确定启用该用户吗?")){
                    document.form1.action="<%=basePath%>doctchangeStatus?docid="+docid+"&sts=1";
                    document.form1.submit();
                }
            }
        }

        function modify(id){
            if (confirm("您确定要修改此用户的信息吗？")) {
                window.location.href ="<%=basePath%>modifyDoctController?id="+id;
            }
        }

        $(function(){
            $.ajax({//查询科室
                url:"<%=basePath%>deptList",
                dataType : "json",
                //编码设置
                contentType : "application/json;charset=utf-8",
                success : function(data) {
                    for(var i=0;i<data.length;i++){
                        $("#departid").append("<option value='" + data[i].departid + "' >" + data[i].name + "</option>");
                    }
                },
                error:function(msg){
                    alert("后台服务器出错，请联系系统管理员");
                }
            });
        });

        function gotoPage(pn){
            if(null != pn && pn!=''){
                document.form1.action="<%=basePath%>doctListController?pn="+pn;
            }
            document.form1.submit();
        }
    </script>
    <style type="text/css">
        body {
            background:#FFF
        }
    </style>
</head>
<body>
<div id="contentWrap">
    <!--表格控件 -->
    <form action="<%=basePath%>doctListController" method="post" name="form1">
        <div id="widget table-widget">
            <div class="pageTitle">医生管理</div>
            <div class="querybody">
                <ul class="seachform">
                    <li><label>医生名称</label><input name="realname" type="text" class="scinput" /></li>
                    <li><label>科室</label>  <!-- 从数据库科室表里面查询出科室id和科室名称，组合成下拉框 -->
                        <select style="width:150px;height:32px;" name="departid" id="departid">
                            <option value="">--请选择--</option>
                        </select>
                    </li>
                    <li><label>&nbsp;</label><input name="" type="submit" class="scbtn" value="查询"/></li>
                </ul>
            </div>
            <div class="pageColumn">
                <div class="pageButton"><a href="<%=basePath%>doct/doctAdd.jsp"><img src="<%=basePath%>images/t01.png" title="新增"/></a><span>医生列表</span></div>
                <table>
                    <thead>
                    <th width="">医生ID</th>
                    <th width="">医生名</th>
                    <th width="">真实姓名</th>
                    <th width="">所属科室</th>
                    <th width="">职称</th>
                    <th width="">联系电话</th>
                    <th width="">年龄</th>
                    <th width="">性别</th>
                    <th width="">家庭住址</th>
                    <th width="">状态</th>
                    <th width="10%">操作</th>
                    </thead>
                    <tbody>
                    <c:forEach items="${pageInfo.list}" var="doct" >
                        <tr>
                            <td>${doct.docid}</td>
                            <td>${doct.name}</td>
                            <td>${doct.realname}</td>
                            <td>${doct.deptname}</td>
                            <td><c:if test="${doct.positional =='01' }">技师</c:if>
                                <c:if test="${doct.positional =='02' }">主任医师</c:if>
                                <c:if test="${doct.positional =='03' }">专家</c:if></td>
                            <td>${doct.age}</td>
                            <td><c:if test="${doct.sex =='1' }">男</c:if> <c:if
                                    test="${doct.sex =='0' }">女</c:if></td>
                            <td>${doct.tel}</td>
                            <td>${doct.address}</td>
                            <td><c:if test="${doct.status =='1' }">启用</c:if>
                                <c:if test="${doct.status =='0' }">禁用</c:if></td>
                            <td>
                                <a onclick="modify('${doct.docid}')"><img src="<%=basePath%>images/icon/edit.png" width="16" height="16" /></a>
                                <c:if test="${doct.status=='1' }">
                                    <a onclick="doctchangeStatus('${doct.docid }','1')"><img src="images/icon/dis.png" width="16" height="16" /></a>
                                </c:if>
                                <c:if test="${doct.status=='0' }">
                                    <a onclick="doctchangeStatus('${doct.docid }','0')"><img src="images/icon/on.png"  width="16" height="16" /></a>
                                </c:if>
                            </td>
                        </tr>
                    </c:forEach>
                    </tbody>
                </table>
            </div>
        </div><!-- #widget -->
        <div id="pagination" style="align:right;margin-top:-10px;">
            <div id='project_pagination' class="pagination pagination-centered">
                <div class="pagination">
                    <ul>
                        <li><a href="javascript:void(0);" onclick="gotoPage(1)">首页</a></li>
                        <li><a href="javascript:void(0);" onclick="gotoPage(${pageInfo.pageNum-1})">上一页</a></li>
                        <li><a href="javascript:void(0);" onclick="gotoPage(${pageInfo.pageNum+1})">下一页</a></li>
                        <li><a href="javascript:void(0);" onclick="gotoPage(${pageInfo.pages})">尾页</a></li>
                    </ul>
                    <ul>
                        <li><span>共&nbsp;&nbsp;${pageInfo.total} 条记录&nbsp;&nbsp;</span></li>
                        <li><span>当前显示第&nbsp;${pageInfo.pageNum }&nbsp;页</span></li>
                    </ul>
                </div>
            </div>
        </div>
    </form>
</div>
</body>
</html>